<template>
  <div class="shopping">
    <div class="bg"></div>
    <div class="container" v-if="data">
      <span class="title">{{ title }}</span>
      <div class="hr"></div>
      <div class="main">
        <div class="flitem" v-for="(v, k) of data.details" :key="k">
          <Flitem
            :img="v.img"
            :title="v.title"
            :price="v.price"
            @click.native="godetail($route.query.index, k)"
          />
        </div>
      </div>
      <ul class="page">
        <li>上一页</li>
        <li v-for="i of 5" :key="i" :class="{ now: now == i }">
          {{ i }}
        </li>
        <li>下一页</li>
      </ul>
    </div>
  </div>
</template>

<script>
import Flitem from "../components/Flitem";
export default {
  components: { Flitem },
  data() {
    return {
      data: null,
      now: 1,
    };
  },
  computed: {
    title() {
      return this.$route.query.type;
    },
  },
  methods: {
    godetail(index, i) {
      this.$router.push("/details?index=" + index + "&i=" + i);
    },
  },
  watch: {
    $route() {
      this.axios.get("json/headerfl.json").then((res) => {
        this.data = res.data.res[this.$route.query.index];
        console.log(this.data);
      });
    },
  },
  mounted() {
    this.axios.get("json/headerfl.json").then((res) => {
      this.data = res.data.res[this.$route.query.index];
      console.log(this.data);
    });
  },
};
</script>

<style lang="scss" scoped>
$fc: #ff6637;
.shopping {
  .container {
    margin-bottom: 16px;
  }
  .bg {
    width: 100%;
    height: 450px;
    background: url("../assets/swiper/2.png") no-repeat;
    background-position-x: center;
  }
  .title {
    margin-top: 16px;
    display: inline-block;
    padding: 12px 20px;
    color: $fc;
    font-size: 16px;
    border-bottom: 2px solid $fc;
  }
  .hr {
    height: 1px;
    background-color: #eaeaea;
  }
  .main {
    width: 100%;
    padding: 32px 12px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .flitem {
    box-sizing: border-box;
    flex: 0 0 25%;
    padding: 16px 8px;
  }
  .page {
    margin: 32px 0 64px 0;
    font-size: 14px;
    color: #666;
    display: flex;
    justify-content: center;
    li {
      margin: 0 8px;
    }
    .now {
      color: $fc;
    }
  }
}
</style>
